<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<script>
	$(document)
			.ready(
					function() {
						var _form=$("#scholarshipForm").validate();
						$('#btnBack')
								.click(
										function() {
											document.scholarshipForm.action = "${basePath}/scholarship/scholarshipStudentIndex";
											document.scholarshipForm.submit();
										});
						//保存
						$("#btnSave").click(function() {
							if(_form.form()){
								valdateRepStudentScholarship("btnSave",1);
								//document.scholarshipForm.action ="${basePath}/scholarship/addRecommendStudent";
			       		  		//document.scholarshipForm.submit();  
							 
							}
						});
					  //保存继续新增
						$("#btnSave2").click(function() {
							if(_form.form()){
								valdateRepStudentScholarship("btnSave2",2);
								//  document.scholarshipForm.action ="${basePath}/scholarship/addRecommendStudent";
								//  document.scholarshipForm.submit()
							}
						});
						  //取消
						$("#btnSave3").click(function() {
							  layer.confirm("您是否确定取消?", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
								  $("#btnSave3").attr("disabled","disabled");
								  document.scholarshipForm.action ="${basePath}/scholarship/addScholarshipStudentForward";
								  document.scholarshipForm.submit();
							  },function(index){
									layer.close(index);
							  });
								
						});
					});
    //验证学生申请奖学金是否条件
     function valdateScholarship(param1,param2){
     	var jxjdj=$('input[name="jxjdj"]:checked').val();
     	if(jxjdj!=null&&jxjdj!=""){
    		$.ajax({
                type: "post",
                url: "${basePath}/scholarship/valdateStudentScholarship",
                data: { xsid :$("#stuid").val(),xnd:$("#xnd").val(),jxjdj:jxjdj},
                success: function(data){
             	   if(data=="1"){  //符合条件
             		  $("#"+param1).attr("disabled","disabled");
             		 $("#flag").val(param2);
       		  		document.scholarshipForm.action ="${basePath}/scholarship/addStudentScholarship";
       		  		document.scholarshipForm.submit();  
       		      }else{ //不符合条件
       		    	 if(data=="21"){
       		    		layer.alert("你不符合一等奖学金申请条件，请你选择符合条件的选项", {icon: 6});
       		    	    return false;
       		    	 }else if(data=="22"){
       		    		layer.alert("你不符合二等奖学金申请条件，请你选择符合条件的选项", {icon: 6});
       		    	    return false;	 
       		    	 }else if(data=="23"){
       		    	  layer.alert("你不符合三等奖学金申请条件，请你选择符合条件的选项", {icon: 6});
        		       return false; 
       		    	 }else{
        		       layer.alert("服务器异常", {icon: 6});
         		       return false;	  
        		      }      
                }
                }
   	   		}); 	
    		
     		
     	}else{
     		  layer.alert("请选择奖学金等级", {icon: 6});
     	  //$("#msg01").html("请选择奖学金等级信息");
     	  return false;
     	}
     }
     function valdateRepStudentScholarship(param1,param2){
			$.ajax({
             type: "post",
             url: "${basePath}/scholarship/valdateRepStudentScholarship",
             data: { xsid :$("#stuid").val(),xnd:$("#xnd").val(),sqid :null},
             success: function(data){
          	   if(data=="1"){  //重复
          		   layer.alert("你已经申报过奖学金信息", {icon: 6});
       		       return false;
          	   }else if(data=="0"){
          			valdateScholarship(param1,param2);
          	   }else{
       			  layer.alert("服务器异常", {icon: 6});
     		       return false;	 
     		 }
    		       
             }
	   		});  
	  }
</script>
</head>
<body style="height: 100%">
	<form action="#" id="scholarshipForm" name="scholarshipForm">
		<input type="hidden" name="token" value="${token}" />
		<input  type="hidden" id="flag" name="flag" value=""/>
		<table cellpadding="0" cellspacing="0" border="0" class="table-border"
			width="95%">
			<tr>
				<td class="table-header" colspan="6">奖学金申请表</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%;"><font color="red">*</font>姓名：</td>
				<td class="table-contentTD" style="width: 22%">${student.xm}<input type="hidden" id="stuid" name="stuid" value="${student.xsid}"/></td>
				<td class="table-titleTD"  style="width: 12%">学号：</td>
				<td class="table-contentTD" style="width: 22%">${student.xh}</td>
				<td class="table-titleTD" style="width: 12%">性别：</td>
				<td class="table-contentTD" style="width: 22%">${student.xb}</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%">班级：</td>
				<td class="table-contentTD" style="width: 22%">${student.bjmc}<input type="hidden" id="bjid" name="bjid" value="${student.bjid}"/></td>
				<td class="table-titleTD" style="width: 12%">专业：</td>
				<td class="table-contentTD" style="width: 22%">${student.zymc}</td>
				<td class="table-titleTD" style="width: 12%">年级：</td>
				<td class="table-contentTD" style="width: 22%">${student.njmc}</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%"><font color="red">*</font>民族：</td>
				<td class="table-contentTD" style="width: 22%"><select id="mz" name="mz" class="required selectList" placeholder="请选择民族">
						<option value="">请选择</option>
							<c:forEach items="${nationList}" var="nation">
								<option value="${nation.codename}">${nation.codename}</option>
							</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%">身份证件号码：</td>
				<td class="table-contentTD" style="width: 22%">${student.sfzh}</td>
				<td class="table-titleTD" style="width: 12%">出身日期：</td>
				<td class="table-contentTD" style="width: 22%"><fmt:formatDate value="${student.csrq}" pattern="yyyy-MM-dd"/></td>
			</tr>
			 <tr>
			 <td class="table-titleTD" style="width: 12%"><font color="red">*</font>政治面貌：</td>
				<td class="table-contentTD" style="width: 22%"><select id="zzmm" name="zzmm" class="required selectList" placeholder="请选择政面貌">
						<option value="">请选择</option>
							<c:forEach items="${sysCodeList}" var="code">
								<option value="${code.codename}">${code.codename}</option>
							</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%">家庭地址：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" id="jtdz" name="jtdz" class="inputText" autocomplete="off" value="${student.jtdz}"></td>
				<td class="table-titleTD" style="width: 12%">邮政编码：</td>
				<td class="table-contentTD" style="width: 22%"><input type="text" id="yzbm" name="yzbm" class="inputText" autocomplete="off" value="${student.yzbm}"/></td>
			 </tr>
				<tr>
				<td class="table-titleTD" style="width: 12%"><font color="red">*</font>学年：</td>
				<td class="table-contentTD" style="width: 22%"><select id="xnd" name="xnd" class="required selectList" placeholder="请选择学年" onchange="javascript:getRecommendStudentScore(this.value);">
					<option value="">请选择</option>
					<c:forEach items="${yearList}" var="y">
						<option value="${y.xnd}">${y.xnd}</option>
					</c:forEach>
				</select></td>
				<td class="table-titleTD" style="width: 12%"><font color="red">*</font>奖学金等级：</td>
				<td class="table-contentTD" style="width: 22%" colspan="3"><input type="radio" id="jxjdj" name="jxjdj" value="1"/>1&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="2"/>2&nbsp;&nbsp;<input type="radio" id="jxjdj" name="jxjdj" value="3"/>3
				 <span id="msg01" style="color: red;"></span>
				</td>
			</tr>
			<tr>
			<td class="table-titleTD">家庭成员：</td>
			<td colspan="5">
			<%@ include file="/module/studentFamily.jsp"%>
			</td>
			</tr>
		  <tr>
		  <td class="table-titleTD" style="width: 12%">第一学期操行评定等级</td>
		  <td class="table-contentTD" style="width: 22%">${cxGrade1}</td>
		  <td class="table-titleTD" style="width: 12%">第二学期操行评定等级</td>
		  <td class="table-contentTD" style="width: 22%">${cxGrade2}</td>
		  <td class="table-titleTD" style="width: 12%"></td>
		  <td class="table-contentTD" style="width: 22%"></td>
		  </tr>
		  <tr>
		  <td class="table-titleTD">学年学习情况：</td>
		  <td colspan="5" id="table_course">
		  <%@ include file="/module/studentCourse.jsp"%>
		  </td>
		  </tr>
			<tr>
			<td class="table-titleTD"><font color="red">*</font>获奖情况：</td>
			<td colspan="5" class="table-contentTD">
			<textarea  id="hjqk" name="hjqk" style="width: 90%;height: 80px;" placeholder="请输入获奖情况" class="required"></textarea>
			</td>
			</tr>
			<tr>
			<td class="table-titleTD"><font color="red">*</font>申请理由：</td>
			<td colspan="5" class="table-contentTD">
			<textarea  id="sqly" name="sqly" style="width: 90%;height: 80px;" placeholder="请输入申请理由"  class="required"></textarea>
			</td>
			</tr>
		</table>
		<br />
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
				<td><input type="button" id="btnSave" autocomplete="off"  class="inputButton"
					style="text-align: center;" value="保存" autocomplete="off" /></td>
				<td><input type="button" id="btnSave2" autocomplete="off"  class="inputButton"
					style="text-align: center;" value="保存并新增" autocomplete="off" /></td>
				<td><input type="button" id="btnSave3" autocomplete="off"  class="inputButton"
					style="text-align: center;" value="取消" autocomplete="off" /></td>
				<td><input type="button" id="btnBack" autocomplete="off"  class="inputButton"
					value="返回" style="text-align: center;" autocomplete="off"/></td>
			</tr>
		</table>
	</form>
</body>
	<script type="text/javascript">
	 compareListValue(document.getElementById('mz'),'${student.mz}');
	 compareListValue(document.getElementById('xnd'),'${xnd}');
	 compareListValue(document.getElementById('zzmm'),'${student.zzmm}');
	 if("${msg}"!=""){
	       layer.alert("${msg}", {icon: 6});
	  } 
</script>
</html>
